# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libnvme
pkgver=1.8
pkgrel=1
pkgdesc="C Library for NVM Express on Linux"
url="https://github.com/linux-nvme/libnvme/"
arch="all"
license="LGPL-2.1-or-later"
depends_dev="
	json-c-dev
	linux-headers
	openssl-dev
	"
makedepends="
	$depends_dev
	bash
	dbus-dev
	meson
	python3-dev
	swig
	util-linux-dev
	xz
	"
checkdepends="diffutils"
subpackages="${pkgname}mi:mi $pkgname-dev py3-nvme:_py3"
source="https://github.com/linux-nvme/libnvme/archive/v$pkgver/libnvme-v$pkgver.tar.gz
	doc-test.patch
	sysfs-test-getc-eof.patch
	"

build() {
	abuild-meson \
		-Db_lto=true \
		-Ddocs=false \
		. output
	meson compile -C output
}

check() {
	meson test --print-errorlogs -C output || [ "$CARCH" = "s390x" ]
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

_py3() {
	pkgdesc="$pkgdesc (python bindings)"
	amove usr/lib/python3*
}

mi() {
	amove usr/lib/libnvme-mi.so.*
}

sha512sums="
ba0cec72fd6c9bb29b29c4342be7b25aec1f31157a094ad387a1105cbd1961ab600e1448a2462d8be2af91d5251b2970d6d06d4871ce96604c5be204d6096bcb  libnvme-v1.8.tar.gz
6ca036287d964db018a2ddfb5480b0b46e6f2edd9f0a7c39dbf5977ce58d8da4d619705e16a3f269bfa7c619d6da5aeff20d9b558c697f6d68e5d89a73ef586e  doc-test.patch
5c417a296fb9fcf4ef3f617017d1bc2bfc450eb7cea808c5560728a25f3bf584a8b8973c299acff8e303100cbc93d2ac01746873bd931112b1a9305e74194b9f  sysfs-test-getc-eof.patch
"
